﻿<%--
 *  File:    VisitPlanEditSummary.jsp
 *  @Author: KentZhong 
 *  Date:    2009-10-9 10:02:44
 *
 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>


<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
    String strModuleName = "SFE";
    String privilegeCode = "H0255,H0256,H0258";
  	String contextPath = request.getContextPath();
  	java.util.HashMap userInfo = (java.util.HashMap)session.getAttribute("userinfo"); 
	Integer nCurOrgId = (Integer)userInfo.get("orgid");
%>

<%--@ include file="/inc/Security.inc" --%>
<%@ include file="/inc/Security.inc"%>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<html>
<head>
<title>VisitPlanFeedbackOneDay</title>
<PageFlow:CheckPageFlow pageName="p_visitplanfeedbacksummary"/>
	<style>
.current_day
{
			background-color:#fed99d;
}
.disabled_day
{
	background-color:#F3F3F3;
}
	</style>	
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script>
	function page_selecteddaybak(nyear,nmonth,nweek,nday,ndate,ndetailid,processid,uprocessid,globalpccode)
	{
		var strUrl="";
		var vwidth=(screen.availWidth - 10);
		var vheight=(screen.availHeight-50);
	    //strUrl="VisitPlanFeedbackDetail.jsp?ishistory=<custom:write property="ishistory"/>&customerid="+ndetailid+"&processid="+processid+"&contactid=<custom:write property="contactid"/>&orgid=<custom:write property="orgid"/>";
		//strUrl="VisitPlanFeedbackSummaryFrm.jsp?ishistory=<custom:write property="ishistory"/>&customerid="+ndetailid+"&processid="+processid+"&contactid=<custom:write property="contactid"/>&orgid=<custom:write property="orgid"/>";
		strUrl="ToVisitPlanFrm.jsp?ishistory=<custom:write property="ishistory"/>&customerid="+ndetailid+"&processid="+processid+"&uprocessid="+uprocessid+"&contactid=<custom:write property="contactid"/>&globalpccode="+globalpccode;
		strUrl=strUrl+"&year="+nyear+"&monthofyear="+nmonth+"&weekofmonth="+nweek+"&dayofweek="+nday+"&dayofmonth="+ndate;
		strUrl=strUrl+"&<%= OvalTools.randomURL() %>"+"&leaderchange=y";
	   var status="height="+vheight+", width="+vwidth+",top=60,left=80,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
       if(popwindow!=null)
       popwindow.close();
       popwindow=window.open(strUrl, "newwindow", status);
	}
	function page_selectedday(nyear,nmonth,nweek,nday,ndate)
	{
		//page_selectedweek(nyear,nmonth,nweek);
		var strUrl="VisitPlanFeedbackOneDay.jsp?ishistory=<custom:write property="ishistory"/>&contactid=<custom:write property="contactid"/>&orgid=<custom:write property="orgid"/>";
		strUrl=strUrl+"&year=<custom:write property="year"/>&monthofyear=<custom:write property="monthofyear"/>&weekofmonth="+nweek+"&dayofweek="+nday+"&dayofmonth="+ndate;
		strUrl=strUrl+"&<%= OvalTools.randomURL() %>";
		var vwidth=(screen.availWidth - 10);
		var vheight=(screen.availHeight-50);
		var status="width="+vwidth +",height="+vheight +",scrollbars,resizable=yes,toolbar=no";
    if(popwindow!=null)
      popwindow.close();
   popwindow=window.open(strUrl, "newwindow", status);
	}
	function page_selectedweek(nyear,nmonth,nweek)
	{
		radiotrue("rdo_week"+nweek);
		var cform = document.cform;
		cform.week.value=nweek;
	}
	function page_other(nyear,nmonth,nweek,nday,visitplandetailid,activitytype,flag)
	{
		var strUrl="";
		var vwidth=(screen.availWidth - 10);
		var vheight=(screen.availHeight-50);
		 if(flag=="disabled"){
		    flag="isview";
		 }
        strUrl="OtherVisitPlanMain.jsp?ishistory=<custom:write property="ishistory"/>&visitplandetailid="+visitplandetailid+"&contactid=<custom:write property="contactid"/>";
		strUrl=strUrl+"&year="+nyear+"&monthofyear="+nmonth+"&weekofmonth="+nweek+"&dayofweek="+nday+"&vflag="+flag;
		strUrl=strUrl+"&<%= OvalTools.randomURL() %>"+"&leaderchange=y";
	    var status="height="+vheight+", width="+vwidth+",top=60,left=80,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
       if(popwindow!=null)
       popwindow.close();
       popwindow=window.open(strUrl, "newwindow", status);
	}
	
	function popWindowShowContactPage(){
		var url = "ContactInfo4Nova.jsp?"+"<%= OvalTools.randomURL() %>"+"&orgid=1&languagecode=<%=strLanguageCode%>&contactid=<custom:write property="contactid"/>&orgid=<%=JspHelper.filterNull(nCurOrgId)%>";
		var windowAttribute = "height=400, width=800,top=100,left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
		if(popwindow!=null)
	    popwindow.close();
	  	popwindow = window.open(url,'ContactInfo',windowAttribute);
	}

	function set_contactNameByPopWindow(id,name,code){
		
		document.cform.username.value=code;
		document.cform.employeename.value=name;
		document.cform.contactid.value=id;
		//alert(id);

	}
	function page_go(){
	    var	contactid=document.cform.contactid.value;
		parent.location.href="VisitPlanFeedbackFrm.jsp?contactid="+contactid+"&ishistory=N";
	}
</script>	
</head>

<body>
	<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
    <input type="hidden" name="pagename" value="p_visitplanfeedbacksummary">
    <input type="hidden" name="actionname">
    <custom:hidden property="contactid"/>
    <custom:hidden property="orgid"/>
    <custom:hidden property="year"/>
    <custom:hidden property="monthofyear"/>
    <custom:hidden property="ishistory"/>	
    <input type="hidden" name="week"/>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
   	<%
   	Integer oYear=(Integer)pageContext.getAttribute("year");
   	Integer oMonth=(Integer)pageContext.getAttribute("monthofyear");
   
   	Calendar cal=Calendar.getInstance();
		cal.set(Calendar.YEAR,oYear.intValue());
		cal.set(Calendar.MONTH,oMonth.intValue()-1);
		cal.set(Calendar.DATE,1);
		cal.setFirstDayOfWeek(Calendar.MONDAY);
		int theFirstDayOfWeek=cal.get(Calendar.DAY_OF_WEEK )-1;
		if (0 == theFirstDayOfWeek) {  
			theFirstDayOfWeek = 7;  
	    }  
		int theLastDayOfMonth=cal.getActualMaximum(Calendar.DAY_OF_MONTH );
		int theLastWeekOfMonth=cal.getActualMaximum(Calendar.WEEK_OF_MONTH);
		java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat(label.getLabelName("L_YearAndMonthFormat"));
		String strYearAndMonth=sdf.format(cal.getTime());
   	%>
   	<tr><td class="summary_top"></td></tr>
   		<tr><td class="summary_top"></td></tr>
   <tr>
		<td class="title_center"><B><u><%=label.getLabelName("L_VisitActivityFeedback")%>[<%=strYearAndMonth%>]</u></B></td>
	</tr>	
	<tr><td class="summary_top">
	 <table width="100%" border="0" cellspacing="0">
          <tr>
           		<td width="350"><%=label.getLabelName("L_Delegacy") + label.getLabelName("L_Colon")%>&nbsp;
           		<custom:text name="contactinfo" property="username"   label="L_ContactId" onchange="javascript:setcontactname(this);" readonly="true"/>
					<a onclick="javascript:popWindowShowContactPage();">
					<custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> 
					<custom:text name="contactinfo" property="employeename" size="20" label="L_ContactId" readonly="true" />
				</td>
  				<td><a href="javascript:page_go()"><img src="../images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a></td>
            </tr>
            
          </table>
	</td></tr>
	<tr>
		<td>
			   <div style="overflow:auto;height:280">
			<table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">

        <tr class="deepblue-left">
          <td width="14%" class="title_center"><%=label.getLabelName("L_Monday")%></td>
          <td class="title_center"><%=label.getLabelName("L_Tuesday")%></td>
          <td width="14%" class="title_center"><%=label.getLabelName("L_Wednesday")%></td>
          <td width="14%" class="title_center"><%=label.getLabelName("L_Thursday")%></td>
          <td width="14%" class="title_center"><%=label.getLabelName("L_Friday")%></td>
          <td width="14%" class="title_center"><%=label.getLabelName("L_Saturday")%></td>
          <td width="14%" class="title_center"><%=label.getLabelName("L_Sunday")%></td>
         </tr>
         <%
         Vector vDetails=(Vector)pageContext.getAttribute("visitplandetails");
         if(vDetails==null)
         	vDetails=new Vector();
         HashMap oneDetail=null;
         int numCurr=0;
         if(vDetails.size()>numCurr)
         	oneDetail=(HashMap)vDetails.get(numCurr);
         int firstWeek=0;
         int firstDayOfWeek=0;
         if(oneDetail!=null)
         {
         	if(oneDetail.containsKey("weekofmonth"))
         		firstWeek=((Integer)oneDetail.get("weekofmonth")).intValue();
         	if(oneDetail.containsKey("dayofweek"))
         		firstDayOfWeek=((Integer)oneDetail.get("dayofweek")).intValue();
         	
         }	
         String strTRClass="td-listrom";
         int nDay=0;
         for(int i=1;i<=theLastWeekOfMonth;i++)
         {
	         
         %>
         
         	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='none'"  > 
         		 <!--
             <td height="22">
               <input type="radio" id="rdo_week<%=i%>" name="checkweekradio" value="<%=i%>" class="normalradio">
            </td>-->
            <%
            
            for(int j=1;j<=7;j++)
            {
            	
              
            	if((i==1 && j<theFirstDayOfWeek ) || (i>1 && nDay>=theLastDayOfMonth)){
            %>
            	<td class="disabled_day">&nbsp;</td>
            	<%}else 
            		{
            		nDay++;
            		if(vDetails.size()<=numCurr ){
            		%>
            	<td onMouseOver="this.className='current_day';" onMouseOut="this.className='none';span_day_<%=nDay%>.style.display='none';" onClick="javascript:page_selectedday('<custom:write property="year"/>','<custom:write property="monthofyear"/>','<%=i%>','<%=j%>','<%=nDay%>');" ><span id="span_day_<%=nDay%>" style="display:none"><%=nDay%></span>&nbsp;
            	<%out.println(nDay);%>
            	</td>
            	
            	<%}else if(oneDetail!=null && (i>firstWeek  || (i==firstWeek && j>=firstDayOfWeek))){
            		%>
            	
            		<%
            		
            		int nCurrWeek=((Integer)oneDetail.get("weekofmonth")).intValue();
            		int nCurrDayOfWeek=((Integer)oneDetail.get("dayofweek")).intValue();
            		if(i==nCurrWeek && j==nCurrDayOfWeek)
            		{
            		%>
            		<td onMouseOver="this.className='current_day';" onMouseOut="this.className='none';span_day_<%=nDay%>.style.display='none';" onClick="javascript:page_selectedday('<custom:write property="year"/>','<custom:write property="monthofyear"/>','<%=i%>','<%=j%>','<%=nDay%>');" ><span id="span_day_<%=nDay%>" style="display:none"><%=nDay%></span>&nbsp;
            		<%out.println(nDay);%>
            		<table width="100%" border="0" cellspacing="0" cellpadding="0">
            			<%
            		int rownum = 0;
            		String strCustomerName="";
            		while(i==nCurrWeek && j==nCurrDayOfWeek)
            		{
            			strCustomerName=(String)oneDetail.get("customername");
            			Integer nCUstomerID=(Integer)oneDetail.get("customerid");
            			Integer processid=(Integer)oneDetail.get("processid");
            			Integer uprocessid=(Integer)oneDetail.get("uprocessid");
            			Integer globalpccode=(Integer)oneDetail.get("globalpccode");
            			rownum ++;
            			//System.out.print(oneDetail);activityname
            			//System.out.print("activitytype="+oneDetail.get("activitytype"));
            		%>
            		<tr>
            			<td class="title_center">&nbsp; 
            			
            			<% if(((Integer)oneDetail.get("activitytype")).intValue()==1) {
            				
            			%>         			
            			    <%=rownum%><%="."%><%=strCustomerName%>
            			<%}else{ 
            				pageContext.setAttribute("activitytype",oneDetail.get("activitytype"));
        					pageContext.setAttribute("displayflag","view");
            			%>
					        <%=rownum%><%="."%>(<custom:selectdic property="activitytype" dictType="ZVisitProcessType"  />)
						 <%
						     pageContext.removeAttribute("displayflag");
            			   } %>
            			</td>
            		<%
            			numCurr++;
            			if(vDetails.size()>numCurr)
            			{
            				oneDetail=(HashMap)vDetails.get(numCurr);
            			}
            			else
            				break;
            		  nCurrWeek=((Integer)oneDetail.get("weekofmonth")).intValue();
            		  nCurrDayOfWeek=((Integer)oneDetail.get("dayofweek")).intValue();
            		%>
            	</tr>
            			
            		<%}
            		%>
            </table>
            </td>
            
            	<%}else{
            		%>
            	<td onMouseOver="this.className='current_day';" onMouseOut="this.className='none';span_day_<%=nDay%>.style.display='none';" onClick="javascript:page_selectedday('<custom:write property="year"/>','<custom:write property="monthofyear"/>','<%=i%>','<%=j%>','<%=nDay%>');"><span id="span_day_<%=nDay%>" style="display:none"><%=nDay%></span>&nbsp;
            	<%out.println(nDay);%>
            	</td>
            <%}
            }
          else{
          	%>
          	<td onMouseOver="this.className='current_day';" onMouseOut="this.className='none';span_day_<%=nDay%>.style.display='none';" ><span id="span_day_<%=nDay%>" style="display:none"><%=nDay%></span>&nbsp;
          	<%out.println(nDay);%>
          	</td>
            	
          	<%
          		}
            }
            }%>
            
          </tr>  
          <%}%>
        </table>
		</td>
	 </tr>	
   </table>	 
     </div> 
  </form>  
</body>

</html>



